package com.tom.controller;

import com.tom.common.resp.R;
import com.tom.entity.Demo;
import com.tom.service.DemoService;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/demo")
@Slf4j
public class DemoController {

    @Resource
    private DemoService demoService;


    @PostMapping("/add")
    public R add(@RequestBody @Valid Demo demo){
        return R.okDate(demoService.add(demo));

    }
    @GetMapping("/{id}")
    public R query(@PathVariable Long id){
        return R.okDate(demoService.query(id));

    }
}
